﻿using mars_server.csharp.AO;
using mars_server.csharp.AO.impl;
using mars_server.csharp.dao;
using mars_server.csharp.dao.impl;
using mars_server.csharp.model;
using mars_server.csharp.socket;
using mars_server.csharp.myTask;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using mars_server.csharp.Util;
using mars_server.csharp.cache;

namespace mars_server
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("            +------------------------------------+");
            Console.WriteLine("            |                                    |");
            Console.WriteLine("            |        欢迎来到火星聊天室服务器    |");
            Console.WriteLine("            |                                    |");
            Console.WriteLine("            +------------------------------------+");
            //单例对象实例化
            RelationAO relationAO = RelationAOImpl.Instance; 
            ServerSocket serverSocket = ServerSocket.Instance;

            

            Thread listenerThread = new Thread(serverSocket.initSocketLisetener); //监听对象创建
            listenerThread.IsBackground = true; 
            listenerThread.Start();
            ThreadCountTool.addThreadNum();

            Thread selectThread = new Thread(ServerTask.selectTask); //异步轮询操作
            selectThread.IsBackground = true;
            selectThread.Start();
            ThreadCountTool.addThreadNum();

            Thread heartBeatThread = new Thread(ServerTask.HeartBeatTask); //心跳探测线程
            heartBeatThread.IsBackground = true;
            heartBeatThread.Start();
            ThreadCountTool.addThreadNum();

            Console.WriteLine("[info]|--当前线程数：" + ThreadCountTool.coutThreadNum());



            Console.ReadLine();
        }

     


    }
}
